﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyWPF.Models.Recipe
{
    public interface IRecipe
    {
        /// <summary>
        /// 初始化数据库
        /// </summary>
        /// <param name="RecipeDb"></param>
        void LoadDB(RecipeDbContext RecipeDb);

        /// <summary>
        /// 添加配方
        /// </summary>
        /// <param name="Recipe"></param>
        bool AddRecipe(RecipeContext Recipe);

        /// <summary>
        /// 删除配方
        /// </summary>
        /// <param name="Recipe"></param>
        void RemoveRecipe(RecipeContext Recipe);

        /// <summary>
        /// 修改配方
        /// </summary>
        /// <param name="Recipe"></param>
        void ModifyRecipe(RecipeContext Recipe);

        /// <summary>
        /// 查找所有配方
        /// </summary>
        /// <returns></returns>
        RecipeContext[] GetContextsStruct();

        /// <summary>
        /// 查找同名配方
        /// </summary>
        /// <param name="Recipe"></param>
        /// <returns></returns>
        RecipeContext[] GetContextsStruct_Name(RecipeContext Recipe);
    }

    public class RecipeDbContext
    {
        /// <summary>
        /// 数据库路径，不包含数据库后缀
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// 数据库名称
        /// </summary>
        public string DbName { get; set; }

        /// <summary>
        /// 数据库密码
        /// </summary>
        public string Password { get; set; }
    }

    public class RecipeContext
    {
        public RecipeContext()
        {
            Data_1 = new Data_1();
        }
        /// <summary>
        /// ID字段
        /// </summary>
        public LiteDB.ObjectId _id { get; set; }
        /// <summary>
        /// 配方名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 创建者名称
        /// </summary>
        public string Owner { get; set; }

        /// <summary>
        /// 创建者权限等级
        /// </summary>
        public int OwnerPower { get; set; }

        /// <summary>
        /// 配方创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 上一次修改的修改人名称
        /// </summary>
        public string ModifiedBy { get; set; }

        /// <summary>
        /// 上一次修改时间
        /// </summary>
        public DateTime ModifyTime { get; set; }

        /// <summary>
        /// 允许控制，选择后所有人都能修改删除你的配方，不选择则只有你自己或者比你权限大的用户可以控制
        /// </summary>
        public bool AllowControl { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remarks { get; set; }

        public Data_1 Data_1 { get; set; }
    }

    public class Data_1
    {
        /// <summary>
        /// 数据1
        /// </summary>
        public double Data1 { get; set; }

        /// <summary>
        /// 数据2
        /// </summary>
        public double Data2 { get; set; }
    }
}
